<!-- 营收结算年列表页 -->
<template>
    <div class="boxwrapper">
        <el-form :inline="true" :model="ruleForm" class="demo-form-inline">
            <el-form-item label="报表名称：">
                <el-input placeholder="请输入报表名称" v-model.trim="ruleForm.reportFormName" maxlength="20"></el-input>
            </el-form-item>

            <el-form-item>
                <el-button type="primary"  @click="searchList"  id="monitorEnter">查询</el-button>
                <el-button type="primary"  @click="generateReport">生成报表</el-button>
            </el-form-item>
        </el-form>

        <el-table :data="tableData" border style="width: 80%">
            <el-table-column type="index" label="序号" width="50" align="center"></el-table-column>
            <el-table-column label="报表名称" prop="reportFormName" align="center"></el-table-column>
            <el-table-column label="年份" prop="year" align="center"></el-table-column>
            <el-table-column label="营收佣金税前（元)"  prop="revenueCommissionBefore" align="center">
                <template slot-scope="scope">{{scope.row.revenueCommissionBefore | initCash}}</template>
            </el-table-column>
            <el-table-column label="税率%" prop="taxRate" align="center">
                <template slot-scope="scope">
                    <span v-if="scope.row.taxNode==1">——</span>
                    <span v-else>{{scope.row.taxRate}}</span>
                </template>
            </el-table-column>
            <el-table-column label="营收佣金税后" prop="revenueCommissionAfter" align="center">
                <template slot-scope="scope">{{scope.row.revenueCommissionAfter | initCash}}</template>
            </el-table-column>
            <el-table-column label="计提点数%" prop="calProportion" align="center"></el-table-column>
            <el-table-column label="营收分配明细（元）" prop="revenueCommissionAllot" align="center">
                <template slot-scope="scope">{{scope.row.revenueCommissionAllot | initCash}}</template>
            </el-table-column>
        </el-table>

        <div class="pagebar">
          <el-pagination
            background
            layout="total, sizes, prev, pager, next"
            :current-page.sync="ruleForm.pageNum"
            :page-sizes="[10, 20, 30, 40]"
            :page-size="ruleForm.pageSize"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :total="totalSize">
          </el-pagination>
        </div>

    </div>
</template>
<script>
    import api from '@/api/apiPath'
    export default {
        name:'revenueSettlementYear',
        title:'营收结算-年',
        data () {
            return {
                ruleForm:{
                    reportFormName:undefined,
                    pageNum: 0,
                    pageSize: 10,
                },
                totalSize:0,
                tableData:[],
            }
        },
        filters:{
            initCash(cellValue){
                if(cellValue !== 0){
                    return cellValue.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g,",");
                }
                if(cellValue == 0){
                    return "0.00"
                }
            }
        },
        methods:{
            handleCurrentChange(){
                this.getlist()
            },
            handleSizeChange(val){
                this.ruleForm.pageSize = val
                this.getlist();
            },
            getlist(){
                this.axios.post(api.GETREYEARLIST,this.ruleForm).then((res) => {
                  if (res && res.data.code == 200) {
                        this.tableData = res.data.data.data
                        this.totalSize = res.data.data.total
                   }
                }) 
            },
            generateReport(){
                this.$router.push({path:'/revenueSettlementYearReport'})
            },
            searchList(){
                this.ruleForm.pageNum = 1
                this.getlist()
            }
        },
        activated(){
            this.searchList()
        },
        created(){
            this.getlist()
        }
    }

</script>


<style lang="stylus">
    // .boxwrapper .el-table .cell {
    //      text-align: center;
    //      white-space: pre-line !important;
    //  }
</style>